<template>
	<view :style="{'--color':vuex_config.themeColor1}">
		<template v-if="detailForm.pk_id > 0">
			<sww-swipe :list="swipeList" indicatorDots autoplay></sww-swipe>

			<view class="head">
				<view class="name">{{ detailForm.name || '' }}</view>
				<view class="head_bot" v-if="detailForm.title?true:false">
					{{detailForm.title}}
				</view>
			</view>

			<!-- <view class="main_title">
				<view class="title_cont">活动主办方</view>
			</view>
			<view class="main_box sponsor">
				<view class="sponsor_name">xxx小学</view>
				<view class="static">
					<view class="static_l"></view>
					<view class="static_r">
						<view>联系人：李先生</view>
						<view>联系电话：17876516286</view>
					</view>
				</view>
				<view class="spon_txt">
					xxx小学建立与2099年，是世界上最伟大的小学，曾在2000年获得诺贝尔奖。xxx小学建立与2099年，是世界上最伟大的小学，曾在2000年获得诺贝尔奖。xxx小学建立与2099年，是世界上最伟大的小学，曾在2000年获得诺贝尔奖。
				</view>

			</view> -->
			<view class="main_title">
				<view class="title_cont">报名信息</view>
			</view>
			<view class="main_box cell_main">
				<view class="cell_box">
					<view class="label">开始时间：</view>
					<view class="val">{{detailForm.start_date | timeFiter()}}</view>
				</view>
				<view class="cell_box">
					<view class="label">结束时间：</view>
					<view class="val">{{detailForm.end_date | timeFiter()}}</view>
				</view>
				<view class="cell_box">
					<view class="label">联系人：</view>
					<view class="val">{{detailForm.contacts}}</view>
				</view>
				<view class="cell_box">
					<view class="label">联系电话：</view>
					<view class="val">{{detailForm.phone}}</view>
				</view>
			</view>
	
			<template v-if="detailForm.details">
				<view class="main_title">
					<view class="title_cont">活动详情</view>
				</view>
				<view class="main_box">
					<u-parse :html="detailForm.details || ''"></u-parse>
				</view>
			</template>


		</template>
		<sww-login></sww-login>
	</view>
</template>

<script>
	import {
		formatDate,
		isBefore,
		isAfter
	} from '@/utils/moment/index.js'
	export default {
		data() {
			return {
				swipeList: [],
				detailForm: {}
			}
		},
		components: {},
		onLoad(options) {
			if (options && options.id) {
				this.detailForm.pk_id = Number(options.id)
				this.initPage()
			}
		},
		filters: {
			timeFiter(time) {
				return formatDate(time,'YYYY-MM-DD HH:mm')
			}
		},
		methods: {
			initPage() {
				this.$resPost('GetEnrollInfoDetailed', {
					pk_id: this.detailForm.pk_id
				}).then(({
					data
				}) => {
					let current_date = new Date();
					let statusTime = 3
					if (isBefore(current_date, data.start_date)) {
						statusTime = 1;
					} else if (isAfter(current_date, data.end_date)) {
						statusTime = 2;
					}
					this.detailForm = {
						...data,
						statusTime: statusTime
					}
				})
			},

		}
	}
</script>
<style lang="scss">
	page {
		background-color: $www-theme-bg;
	}
</style>
<style lang="scss" scoped>
	.head {
		padding: 0 24rpx;
		background-color: #fff;

		.name {
			padding: 30rpx 0 18rpx;
			color: #3b3a42;
			font-size: 36rpx;
			font-weight: bold;
		}

		.head_bot {
			color: #626262;
			font-size: 26rpx;
			padding-bottom: 28rpx;
			text-indent: 2em;
		}
	}

	.main_title {
		font-size: 34rpx;
		padding: 24rpx 0;
		display: flex;
		justify-content: center;

		.title_cont {
			position: relative;

			&::before {
				content: '';
				background-color: #666;
				height: 1rpx;
				width: 60rpx;
				position: absolute;
				top: 50%;
				transform: scaleY(0.5) translateY(-50%);
				left: -74rpx;
			}

			&::after {
				content: '';
				background-color: #666;
				height: 1rpx;
				width: 60rpx;
				position: absolute;
				top: 50%;
				transform: scaleY(0.5) translateY(-50%);
				right: -74rpx;
			}
		}
	}

	.main_box {
		background-color: #fff;
		padding: 0 30rpx;
		border-radius: 10rpx;
		margin: 10rpx 20rpx;

		&.sponsor {
			padding: 20rpx 20rpx;

			.sponsor_name {
				font-weight: bold;
				font-size: 34rpx;
			}

			.spon_txt {
				font-size: 26rpx;
				text-indent: 2em;
				margin-top: 10rpx;
			}

			.static {
				margin-top: 10rpx;
				display: flex;
				font-size: 24rpx;
				color: #999;
				line-height: 40rpx;
				text-align: right;

				.static_l {
					flex: 1;
					overflow: hidden;
				}
			}
		}

		&.cell_main {
			padding: 16rpx 20rpx;

			.cell_box {
				padding: 10rpx 0;
				display: flex;
				align-items: center;
				justify-content: space-between;
			}
		}
	}
</style>
